package com.fausto.learnimprint.mail

import org.springframework.beans.factory.annotation.Value
import org.springframework.mail.SimpleMailMessage
import org.springframework.stereotype.Component

/**
 * @author: fausto
 * @date: 2022/2/27 16:24
 * @description:
 */
/**
 * 对SimpleMailMessage进行一层封装
 */
@Component
class MailMessage {

    @Value("\${spring.mail.username}")
    lateinit var fromMail: String

    fun create(toMail: String, subject: String, text: String): SimpleMailMessage {
        return SimpleMailMessage().apply {
            setFrom(fromMail)
            setTo(toMail)
            setSubject(subject)
            setText(text)
        }
    }
}